package com.rftennis.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.rftennis.dto.JSONResponce;

import com.rftennis.dto.QueryResult;
import com.rftennis.entity.OrderEntity;
import com.rftennis.service.OrderService;
import com.rftennis.vo.OrderVo;

@Controller
public class OrderController {
	@Autowired
	OrderService service;
	@PostMapping("/order/change.do")
	public @ResponseBody JSONResponce deleteOrder(String id,String status) throws Exception{
		service.deleteOrder(id, status);
		return JSONResponce.ok();
		
	}
	@GetMapping("/order/select.do")
	public @ResponseBody JSONResponce selectOrder(String ordNo) throws Exception{
		OrderEntity e=service.selectOrder(ordNo);
		return JSONResponce.ok(e);
	}
	@GetMapping("/order/selectkey.do")
	public @ResponseBody JSONResponce selectIdKeyOrder(String customerId,String key, String pageNo, String pageSize) throws Exception {
	

		int pageNoInt =Integer.parseInt(pageNo);
		int pageSizeInt =Integer.parseInt(pageSize);
		// 2调用业务方法

		
		QueryResult<OrderEntity> queryResult = service.selectIdKeyOrder(customerId, key, pageNoInt, pageSizeInt);
		QueryResult<OrderVo> queryVoResult=queryResult.rowsMap(OrderVo::of);
		return JSONResponce.ok(queryVoResult);

	}
}
